package com.ztgf.order.service.purchase;

import com.ztgf.order.models.vo.purchase.PurchaseCommodityVO;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.BeanUtils;
import javax.annotation.Resource;
import com.ztgf.order.common.config.YmlConfig;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.ztgf.order.mapper.purchase.PurchaseCommodityMapper;
import com.ztgf.order.models.service.purchase.IPurchaseCommodityService;
import com.ztgf.order.models.bo.purchase.PurchaseCommoditySaveBO;
import com.ztgf.order.models.dto.purchase.PurchaseCommodityDTO;

/**
 * 采购商品表控制器
 *
 * @author mxli
 * @Date 2021-05-17 10:16:25
 */
@DubboService
public class PurchaseCommodityServiceImpl extends ServiceImpl<PurchaseCommodityMapper, PurchaseCommodityDTO> implements IPurchaseCommodityService{

    @Resource
    private YmlConfig ymlConfig;

    @Override
    public boolean add(PurchaseCommoditySaveBO saveBO) {
        PurchaseCommodityDTO dto = new PurchaseCommodityDTO();
        BeanUtils.copyProperties(saveBO,dto);
        Long id = ymlConfig.getPkId();
        dto.setId(id);
        return this.insert(dto);
    }
    @Override
    public PurchaseCommodityVO getPurchaseCommodity(Long purchaseId){
        return baseMapper.getPurchaseCommodity(purchaseId);
    }
}
